Repository navigation
Conversation
This was referenced Sep 30, 2026
vmanvs
force-pushed
the
fix/setwise-score-temperature
branch
from
October 13, 2026 16:52
5f2c4ff to
bbe23eb
Compare
Author
|
@sundar24295s @chanh @fortunecookiee Rebased onto main after #41188, which already passes temperature into the MIS extraction path. This PR is now limited to the |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
#40826 added temperature-scaled scoring, and #38965 added setwise scoring (
score_extraction_token_id). #41188 then added CausalLM setwise and threadedtemperatureinto_process_multi_item_extraction_results, so CausalLM setwise honors it.SequenceClassificationsetwise still does not: both its paths normalize rows in_multi_position_score_rows, which has no temperature. A request withapply_softmax=Trueandtemperature != 1passes validation, but every row is still normalized at temperature 1, so the value is silently ignored.Example: pooled logits
[1.0, 3.0]withtemperature=2.0should scoresoftmax([0.5, 1.5]) = [0.269, 0.731]. BothSequenceClassificationsetwise paths (batched and--enable-mis) return[0.119, 0.881].Pointwise scoring and CausalLM setwise already honor temperature and are unchanged.
Modifications
_multi_position_score_rowstakes a keyword-onlytemperatureand applies the same numerically stable softmax as the pointwise branch: float64, subtract each row's max, then divide by temperature. The argument is required so a new call site cannot silently drop it. Withapply_softmax=False, raw logits are returned unchanged, as before._process_single_item_scoring_resultsand the classification branch of_process_multi_item_extraction_results) passtemperaturethrough; both already receive it.test_setwise_classification_temperatureintest/registered/unit/test_token_scoring.py. It drivesscore_requestend to end through the existingScoringManagerfake (only model execution is faked), for bothenable_mis=Falseandenable_mis=True, with two items that have different anchor counts (1 and 2). It checks every row attemperature=2.0and attemperature=1e-300. The latter guards the float64 computation: in float32,1e-300rounds to 0 and every row becomes NaN. The fake now returns one row per pooled position whentoken_indices_to_poolis set.test_setwise_score_mixin.py: the three direct calls to_multi_position_score_rowspasstemperature=1.0.Rebased onto main after #41188; the source change is now limited to the row helper and its two call sites.
Accuracy Tests
No model forward, kernel, or pooling code changed; only post-processing of the pooled logits. Temperature-1 results are unchanged up to float precision: the softmax now runs in float64, matching the pointwise branch.
Unit tests (CPU, Python 3.11, torch 2.13.0+cpu, WSL2):
Not run: an end-to-end
/v1/scoresmoke test against a real SequenceClassification model.Speed Tests and Profiling
N/A. There is no performance claim: this changes a small softmax on the already-pooled
[num_positions, num_labels]result.Checklist
.pre-commit-config.yaml; the full pre-commit suite was not run.)docs/yet.)CI States
Latest PR Test (Base): ❌ Run #38434296038
Latest PR Test (Extra): ❌ Run #38434296016
Latest PR Test (AMD ROCm 10): ❌ Run #38434295942